<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:72:"C:\phpstudy\WWW\tea\public/../application/entries\view\jren\get_all.html";i:1533895686;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>查看匠人信息</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="favicon.ico"> <link href="/static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/static/css/animate.css" rel="stylesheet">
    <link href="/static/css/style.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
        div{
            text-align: center;
        }
        th{
            text-align: center;
        }
        .fanye{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="ibox-title">
        <h5>查看匠人信息</h5>
    </div>
    <form class="form-horizontal m-t" id="signupForm" action="<?php echo url('getChoose'); ?>" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-sm-1 control-label">茶类</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teacase" style="font-size: 12px;">
                    <option value="10000">查看全部</option>
                    <?php foreach($teacase as $case): ?>
                    <option value="<?php echo $case['id']; ?>" <?php if($current): if($case['id']==$current['id']): ?>selected='selected'<?php endif; endif; ?>><?php echo $case['teaname']; ?></option>
                    <?php endforeach; ?>
                    <option value="9999">其它</option>
                    }
                </select>
            </div>

            <label class="col-sm-1 control-label">产区</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="teaarea" style="font-size: 12px;">
                    <option value="10000">查看全部</option>
                    <?php if($current): foreach($teaarea as $t): ?>
                    <option value="<?php echo $t['id']; ?>" <?php if($currentArea): if($t['id']==$currentArea['id']): ?>selected='selected'<?php endif; endif; ?>><?php echo $t['area']; ?></option>
                    <?php endforeach; ?>
                    <option value="9999">其它</option>
                    <?php endif; ?>
                </select>
            </div>
            <div class="col-sm-2">
                <button class="btn btn-primary" type="submit">提交</button>
            </div>
        </div>
    </form>

    <div class="form-group">

    </div>

    <div class="form-horizontal m-t">
    <div class="form-group">
        <label class="col-sm-1 control-label">显示</label>
        <div class="col-sm-8">
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="contact" id="inlineCheckbox6" >茶类</label>
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="contact" id="inlineCheckbox7" >产地</label>
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="contact" id="inlineCheckbox9" >联系方式</label>
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="briefintro" id="inlineCheckbox4" checked>简介</label>
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="detailintro" id="inlineCheckbox5" checked>详情</label>
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="contact" id="inlineCheckbox8" style="display:none"></label>
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="phone" id="inlineCheckbox2" style="display:none"></label>
            <label class="checkbox-inline" style="float: left;">
                <input type="checkbox" class="wechat" id="inlineCheckbox3" style="display:none"></label>

            <?php if((\think\Session::get('user.grade')==1)): ?>
            <form action="<?php echo url('exportExcel'); ?>" method="post">
                <input type="hidden" value="<?php echo $choosetea; ?>" name="teacase">
                <input type="hidden" value="<?php echo $choosearea; ?>" name="teaarea">
                <button class="btn btn-primary" >导出本页</button>
            </form>
            <?php endif; ?>
        </div>
    </div>
    </div>

    <div class="ibox-content">
        <table class="table table-striped">
        <!-- table -->
            <thead>
                <tr>
                    <th class='rank'>排名</th>
                    <th class='case'></th>
                    <th class='area'></th>
                    <th class="name">匠人姓名</th>
                    <th>匠心指数</th>
                    <th class='contact'></th>
                    <th class='phone'></th>
                    <th class='wechat'></th>
                    <th class='briefintro' >简介</th>
                    <th class='detailintro'>详细介绍</th>
                    <th>上榜</th>
                    <th>修改</th>
                    <?php if((\think\Session::get('user.grade')==1)): ?>
                    <th>删除</th>
                    <?php endif; ?>
                </tr>
            </thead>

            <tbody>
                <?php foreach($data as $onedata): ?>
                <tr index = "<?php echo $onedata['id']; ?>">
                    <td >
                        <?php echo $onedata['rank']; ?>
                    </td >

                    <td >
                        <!-- <input name="chooseteacase" value="<?php echo $onedata['teacase']; ?>" style="width:50px;text-align: center;border: none;display: none;"> -->
                        <select name="chooseteacase" style="display: none;">
                            <?php foreach($teacase as $t): ?>
                            <option value="<?php echo $t['id']; ?>" <?php if($t['teaname'] ==$onedata['teacase']): ?>selected="selected"<?php endif; ?>><?php echo $t['teaname']; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </td >

                    <td >
                        <!-- <input type="" name="chooseteaarea" value="<?php echo $onedata['teaarea']; ?>" style="width:80px;text-align: center; border: none;display: none;"> -->
                        <!--  -->
                        <select name="chooseteaarea" teacase_id = "<?php echo $onedata['teacase_id']; ?>" style="display: none;">
                            <?php foreach($onedata['areas'] as $a): ?>
                                <option value="<?php echo $a['area']; ?>" <?php if($a['area']==$onedata['teaarea']): ?>selected="selected"<?php endif; ?>><?php echo $a['area']; ?></option>
                            <?php endforeach; ?>
                        </select>
                        <!--  -->
                    </td >

                    <td >
                        <input index="<?php echo $onedata['id']; ?> type="text" name="name" value="<?php echo $onedata['name']; ?>" style="width: 80px;text-align: center;border: none;">
                    </td >

                    <td >
                        <input type="text" name="score" value="<?php echo $onedata['score']; ?>" style="width: 80px;text-align: center;border: none;">
                    </td>
                    <td >
                        <input type="text" name="contact" value="<?php echo $onedata['contact']; ?>" style="width: 60px;text-align: center;border: none;display: none;">
                    </td>

                    <td >
                        <input type="text" name="phone" value="<?php echo $onedata['phone']; ?>" style="width: 80px;text-align: center;border: none;display: none;">
                    </td>

                    <td >
                        <input type="text" name="wechat" value="<?php echo $onedata['wechat']; ?>" style="width: 100px;text-align: center;border: none;display: none;">
                    </td>

                    <td >
                        <textarea cols="20" rows="6" name="briefintro" style="border: none;" ><?php echo $onedata['briefintro']; ?></textarea>
                    </td>

                    <td >
                        <textarea cols="50" rows="6" name="detailintro" style="border: none;"><?php echo $onedata['detailintro']; ?></textarea>
                    </td>

                    <?php if($onedata['bangdan_id']==1): ?>
                    <td>
                        <button class="YoN" indexm="<?php echo $onedata['id']; ?>" value="4" style="width: 45px; ">是</button>
                    </td>
                    <?php else: ?>
                    <td>
                        <button class="YoN" indexm="<?php echo $onedata['id']; ?>" value="1" style="width: 45px;color: red;">否</button>
                    </td>
                    <?php endif; ?>
                    <td >
                        <button class="modify" index="<?php echo $onedata['id']; ?>">修改</button>
                    </td>
                    <?php if((\think\Session::get('user.grade')==1)): ?>
                    <td >
                        <button class="del" del="<?php echo $onedata['id']; ?>" data-toggle="modal"  data-target="#delmod">删除</button>

                    </td>
                    <?php endif; ?>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>

    <!-- 删除提示Modal -->
    <div class="modal fade" id="delmod" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">确定要删除吗？</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="id" class="delID">
                    <p>删除后将不可恢复！！！</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-default confirmDel" data-dismiss="modal" >删除</button>
                </div>
            </div>
        </div>
    </div>



<!-- 全局js -->
<script src="/static/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/static/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/static/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/static/js/hAdmin.js?v=4.1.0"></script>
<script type="text/javascript" src="/static/js/index.js"></script>
<script type="text/javascript">

    $("select[name=chooseteacase]").change(function(){
        var teacase_id = $(this).val();
        var area = $(this).parents('tr').find('select[name=chooseteaarea]');
        var url="<?php echo url('reTeaAreaJson'); ?>";
        $.post(url, {teacase_id:teacase_id},function(data){
            var areas = JSON.parse(data);
            var option = '';
            for(index in areas){
                var a = "<option value="+areas[index]['area']+">"+areas[index]['area']+"</option>"
                option +=a
            }
            area.html(option)
        })

    })


    //删除
    $(".del").click(function(){
        var id = $(this).attr("del");
        $("input.delID").val(id);
    })

    //确认删除
    $("button.confirmDel").click(function(){
        var delID = $("input.delID").val();
        var url = "<?php echo url('delJr'); ?>";
        var data = {id:delID};
        $.post(url, data, function(data){
            if(data==1){
                $("tr[index="+delID+"]").remove();
                alert("删除成功");
            }
        });

    })

    //修改
    $(".modify").click(function(){
        var url = "<?php echo url('modifyJren'); ?>";
        var id = $(this).attr("index");
        // var teacase = $(this).parents('tr').find("input[name=chooseteacase]").val();
        // var teaarea = $(this).parents('tr').find("input[name=chooseteaarea]").val();
        var teacase = $(this).parents('tr').find("select[name=chooseteacase]").val();
        var teaarea = $(this).parents('tr').find("select[name=chooseteaarea]").val();
        var name= $(this).parents('tr').find("input[name=name]").val();
        var score =$(this).parents('tr').find("input[name=score]").val();
        var contact =$(this).parents('tr').find("input[name=contact]").val();
        var phone =$(this).parents('tr').find("input[name=phone]").val();
        var wechat =$(this).parents('tr').find("input[name=wechat]").val();
        var briefintro =$(this).parents('tr').find("textarea[name=briefintro]").val();
        var detailintro =$(this).parents('tr').find("textarea[name=detailintro]").val();
        var data = {
            id:id,
            teacase:teacase,
            teaarea:teaarea,
            name:name,
            score:score,
            contact:contact,
            phone:phone,
            wechat:wechat,
            briefintro:briefintro,
            detailintro:detailintro
        }
        $.post(url,data,function(data){
            if(data == 1){
                alert('修改成功');
            }
        })
    })

   $('.YoN').click(function(){
        var url = "<?php echo url('shangbang'); ?>";
        var a = $(this).html();
        var id = $(this).attr("indexm");
        var bangdan_id = $(this).attr("value");
        var data = {
            id:id,
            bangdan_id:bangdan_id
        }
        $.post(url,data,function(data){
            if(data == 1){
                if(a=="是"){
                    $('button[indexm='+id+']').html("否");
                    $('button[indexm='+id+']').attr('value',1);
                    $('button[indexm='+id+']').attr('style',"width: 45px;color: red;");
                }else{
                    $('button[indexm='+id+']').html("是");
                    $('button[indexm='+id+']').attr('value',4);
                    $('button[indexm='+id+']').attr('style',"width: 45px;");
                }
                alert('修改成功');
            }
        })
   })

    //隐藏
    $("#inlineCheckbox1").click(function(){
        var a = $("th[class=contact]").html();
        if(a == '联系人'){
            $("th[class=contact]").html('')
        }else{
            $("th[class=contact]").html('联系人')
        }
        $("input[name=contact]").toggle();

    })


    $("#inlineCheckbox2").click(function(){
        var a = $("th[class=phone]").html();
        if(a == ''){
            $("th[class=phone]").html('电话')
        }else{
            $("th[class=phone]").html('')
        }
        $("input[name=phone]").toggle();

    })

    $("#inlineCheckbox3").click(function(){
        var a = $("th[class=wechat]").html();
        if(a == ''){
            $("th[class=wechat]").html('微信')
        }else{
            $("th[class=wechat]").html('')
        }
        $("input[name=wechat]").toggle();

    })

    // phone wechat briefintro detailintro
    $("#inlineCheckbox4").click(function(){
        var a = $("th[class=briefintro]").html();
        if(a == ''){
            $("th[class=briefintro]").html('简介')
        }else{
            $("th[class=briefintro]").html('')
        }
        $("textarea[name=briefintro]").toggle();

    })

    $("#inlineCheckbox5").click(function(){
        var a = $("th[class=detailintro]").html();
        if(a == ''){
            $("th[class=detailintro]").html('详细介绍')
        }else{
            $("th[class=detailintro]").html('')
        }
        $("textarea[name=detailintro]").toggle();

    })

    $("#inlineCheckbox6").click(function(){
        var a = $("th[class=case]").html();
        if(a == ''){
            $("th[class=case]").html('茶类')
        }else{
            $("th[class=case]").html('')
        }
        $("select[name=chooseteacase]").toggle();

    })
    $("#inlineCheckbox7").click(function(){
        var a = $("th[class=area]").html();
        if(a == ''){
            $("th[class=area]").html('产地')
        }else{
            $("th[class=area]").html('')
        }
        $("select[name=chooseteaarea]").toggle();

    })

    $("#inlineCheckbox8").click(function(){
        var a = $("th[class=contact]").html();
        if(a == ''){
            $("th[class=contact]").html('联系人')
        }else{
            $("th[class=contact]").html('')
        }
        $("input[name=contact]").toggle();

    })
    $('#inlineCheckbox9').click(function(){
        $('#inlineCheckbox2').click()
        $('#inlineCheckbox3').click()
        $('#inlineCheckbox8').click()
    })


    $("select[name=teacase] ").change(function(){
        var val = $(this).find("option:selected").attr("value");
        if(val == 10000){
            var a = "<option value="+10000+">查看全部</option>";
            $("select[name=teaarea]").html(a);
            exit();
        }

        if(val == 9999){
            var a = "<option value="+9999+">其它</option>";
            $("select[name=teaarea]").html(a);
            exit();
        }

        var url="<?php echo url('reTeaAreaJson'); ?>";
        $.post(url, {teacase_id:val},function(data){
            var areas = JSON.parse(data);
            var option="<option value='10000'>查看全部</option>";
            for(index in areas){
                var a = "<option value="+areas[index]['id']+">"+areas[index]['area']+"</option>"
                option +=a
            }
            option +="<option value='9999'>其它</option>";
            $("select[name=teaarea]").html(option)
        })
    })


</script>

</body>
</html>